<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
namespace App\Controller;


use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Yansongda\HyperfPay\Pay;

/**
 * Class PayController
 * @package App\Controller
 * @Controller
 *
 */
class PayController extends AbstractController
{
    /**
     * @RequestMapping(path="wechat/xcx", methods="get")
     * Notes:
     * Author: Bruce.z
     * DateTime: 2022/7/15 10:59
     * @param Pay $pay
     * @return \Yansongda\Supports\Collection
     */
    public function xcx(Pay $pay): \Yansongda\Supports\Collection
    {
        return $pay->wechat()->mini([
            'out_trade_no' => ''.time(),
            'total_amount' => '0.01',
            'subject' => 'yansongda 测试 - 1',
        ]);
    }

    /**
     * Notes:
     * Author: Bruce.z
     * DateTime: 2022/7/15 13:50
     * @param Pay $pay
     * @return \Yansongda\Supports\Collection
     */
    public function map(Pay $pay): \Yansongda\Supports\Collection
    {
        $order = [
            'out_trade_no' => time().'',
            'description' => 'subject-测试',
            'amount' => [
                'total' => 1,
            ],
            'payer' => [
                'openid' => 'onkVf1FjWS5SBxxxxxxxx',
            ],
        ];

        return $pay->wechat()->mp($order);
    }
}
